home *** CD-ROM | disk | FTP | other *** search
- // HTBImage.cpp : Defines the initialization routines for the DLL.
- //
-
- #include "stdafx.h"
- #include "HTBImage.h"
- #include "image.h"
- #include "export.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- //
- // Note!
- //
- // If this DLL is dynamically linked against the MFC
- // DLLs, any functions exported from this DLL which
- // call into MFC must have the AFX_MANAGE_STATE macro
- // added at the very beginning of the function.
- //
- // For example:
- //
- // extern "C" BOOL PASCAL EXPORT ExportedFunction()
- // {
- // AFX_MANAGE_STATE(AfxGetStaticModuleState());
- // // normal function body here
- // }
- //
- // It is very important that this macro appear in each
- // function, prior to any calls into MFC. This means that
- // it must appear as the first statement within the
- // function, even before any object variable declarations
- // as their constructors may generate calls into the MFC
- // DLL.
- //
- // Please see MFC Technical Notes 33 and 58 for additional
- // details.
- //
-
- /////////////////////////////////////////////////////////////////////////////
- // CHTBImageApp
-
- BEGIN_MESSAGE_MAP(CHTBImageApp, CWinApp)
- //{{AFX_MSG_MAP(CHTBImageApp)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- // DO NOT EDIT what you see in these blocks of generated code!
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CHTBImageApp construction
-
- CHTBImageApp::CHTBImageApp()
- {
- // TODO: add construction code here,
- // Place all significant initialization in InitInstance
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // The one and only CHTBImageApp object
-
- CHTBImageApp theApp;
- Image * g_pImageList = NULL;
-
- extern "C"
- {
-
- short Loadimage(char * ImageFilename)
- {
- Image * pNewImage = NULL;
-
- if (g_pImageList != NULL)
- {
- pNewImage = g_pImageList->AddImage();
- }
- else
- {
- g_pImageList = new Image();
- pNewImage = g_pImageList;
- }
-
- pNewImage->LoadImage(ImageFilename);
-
- return(pNewImage->GetID());
- }
-
- void Show(short ID,short Xpos,short Ypos,DWORD RasterOp)
- {
- if (g_pImageList)
- {
- g_pImageList->Show(ID,Xpos,Ypos,RasterOp);
- RefreshScreen();
- }
- }
-
- void Noshow(short ID)
- {
- if (g_pImageList)
- {
- g_pImageList->NoShow(ID);
- RefreshScreen();
- }
-
- }
-
- void On_LeftMouseDown(CPoint * point)
- {
- if (g_pImageList)
- {
- g_pImageList->EvalRegion(*point);
- }
- }
-
- void On_RightMouseDown(CPoint * point)
- {
- if (g_pImageList)
- {
- g_pImageList->EvalRegionForDrag(*point,TRUE);
- }
- }
-
- void On_RightMouseUp(CPoint * point)
- {
- if (g_pImageList)
- {
- g_pImageList->EvalRegionForDrag(*point,FALSE);
- }
- }
-
- void On_MouseMove(CPoint * point)
- {
- if (g_pImageList)
- {
- g_pImageList->SetDraggingToMouse(*point);
- }
- }
-
- void Createregion(short ID,short signal,short AllowDrag)
- {
- if (g_pImageList)
- {
- g_pImageList->CreateRegion(ID,signal,AllowDrag);
- }
-
- SetExportFunction(L_BTN_DOWN,(void *)On_LeftMouseDown);
-
- if (AllowDrag)
- {
- SetExportFunction(R_BTN_DOWN,(void *)On_RightMouseDown);
- SetExportFunction(R_BTN_UP,(void *)On_RightMouseUp);
- SetExportFunction(MOUSE_MOVE,(void *)On_MouseMove);
- }
- }
-
- void On_Draw(HDC hDC)
- {
- if (g_pImageList)
- {
- g_pImageList->Draw(hDC);
- }
- }
-
- void Shutdown()
- {
- SetExportFunction(ON_DRAW,NULL);
- SetExportFunction(L_BTN_DOWN,NULL);
- SetExportFunction(R_BTN_DOWN,NULL);
- SetExportFunction(R_BTN_UP,NULL);
- SetExportFunction(MOUSE_MOVE,NULL);
-
- if (g_pImageList)
- {
- delete g_pImageList;
- g_pImageList = NULL;
- }
-
- }
-
- } // end extern "C"
-
- BOOL CHTBImageApp::InitInstance()
- {
- SetExportFunction(ON_DRAW,(void *)On_Draw);
-
- return CWinApp::InitInstance();
- }
-
-